class Student{
    String name;
    int age;
    void read(){
        System.out.println("大家好，我是"+name+",年龄"+age);
    }
}
public class Example038 {
    public static void main(String[] args) {
        Student stu= new Student();
        stu.name = " 张三 ";
        stu.age = -18;
        stu1.read();
    }
}



class Student{
    private String name;
    private int age;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    private int getAge(){
     return age;
    }
    public void setAge(int age) {
        if (age<=0) {
            System.out.println("您输入的年龄有误");
        } else {
           this.age =age;
        }
    }
    public void read(){
        System.out.println("大家好，我是"+name+",年龄"+age);
    }
}
public class Example04 {
    public static void main(String[] args) {
        Student stu= new Student();
        stu.name = " 张三 ";
        stu.age(-18);
        stu1.read();
    }
}





class Student{
    public Student(){
        System.out.println("调用了无参构造方法");
    }
}
public class Example05 {
    public static void main(String[] args) {
        System.out.println("声明对象...");
        Student stu= null;
        System.out.println("实例化对象...");
        stu = new Student();
    }
}

class Student{
    private String name;
    private int age;
    public Student(String n ,int a ){
        name = n;
        age =a ;
    }
    public void read(){
        System.out.println("大家好，我是"+name+",年龄"+age);
    }
}
public class Example06 {
    public static void main(String[] args) {
        Student stu = new Student("张三", 18);
        stu.read();
    }
}

class Student{
    private String name;
    private int age;
    public Student(){}
    public Student(String n ,int a){
        name = n;
        age = a;
    }
    public void read(){
        System.out.println("大家好，我是"+name+",年龄"+age);
}
}
public class Example07 {
    public static void main(String[] args) {
        Student stu1 = new Student("张三");
        Student stu2 = new Student("张三", 18);
        stu1.read();
        stu2.read();
    }
}

public class Example08{
    public static void main(String[] args) {
        Student stu = new Student();
    }
}




















